home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1986 June
/
Ahoy_Magazine_86-06_1986_Double_L.d64
/
comal and you
< prev
next >
Wrap
Text File
|
2022-10-26
|
9KB
|
332 lines
COMAL AND YOU - For Beginners Only
by David Stidolph
WHY LEARN TO PROGRAM?
The many commercial computer programs
available today are more than
sufficient for most people's needs.
If word processors, spread sheets,
and data base managers are all the
computer is used for, learning to
program would be a waste of time.
For some, however, a goal is being
able to learn something new...
something that can control that
mysterious box called a computer.
There's nothing like the feeling of
accomplishment when you type in your
first working program. Also,
familiarity with computers and
programming helps ease the sense of
helplessness most people get when
dealing with computers. (How did you
feel the first time you got a
computerized bill?) This article is
for people who have made the decision
to not only learn about computers,
but to learn programming as well.
WHAT IS A COMPUTER LANGUAGE?
Computers work with a language of
zeros and ones called machine code.
This is as difficult to use as it
sounds, and few programmers now work
directly in machine code. They choose
instead to use computer "languages".
These range from low level languages
like assembly code, where the words
merely represent individual machine
code instructions, to high level
languages which look more like
english. Compare the following two
programs:
ASSEMBLY CODE
* = START
LDY #0
LP LDA STRING,Y
BEQ ENDLP
JSR OUTPUT
INY
BNE LP
BEQ OUTPUT
.BYT 'This is a string',13,0
ENDLP <...> ; rest of program code
COMAL
PRINT "This is a string"
As you can see, the COMAL program is
shorter and much more readable.
Although the computer will seem to
understand COMAL once the language is
loaded, the computer itself still
only understands machine code. COMAL
is itself a machine code program, but
instead of letting you do word
processing, or other mundane tasks,
it allows you to write, edit, and run
COMAL programs. Think of the language
as an interpreter between you and the
computer. This means you don't have
to learn machine code - you only have
to make sure that the language is in
the machine before you can run your
COMAL programs.
WHY LEARN COMAL?
Since BASIC comes with all personal
computers today, most people think
that it is the best computer language
to learn. Not so. BASIC is
implemented on so many computers
because it is the easiest language to
write. It has the fewest commands,
and NO definite standard to follow
(any arbitrary rules can be forced on
it). This means that a BASIC program
written on one computer may NOT run
on any other computer. BASIC does,
however, have one good feature; the
ability to type in a short program
and see it execute as soon as you
type the word RUN. No text editors or
elaborate compiler commands (needed
in most other high level languages
like Pascal, Fortran or Cobol) are
necessary. This makes BASIC seem like
a easy-to-learn language for
everyone.
COMAL started with this idea of
interactive work with the programmer,
then added to it. Added were things
like the structured code of Pascal,
the graphics of Logo, and a few
tricks of its own. COMAL is now the
language taught in the schools of 5
European countries. COMAL is easier
to learn than BASIC, and teaches the
idea of structured programing
necessary to using modern computer
languages.
HOW DO YOU GET COMAL?
In Europe, the disk based version of
COMAL for the Commodore 64 (version
0.14 - the same as used here in the
U.S.) sells for fifty dollars, and is
copy-protected so that you cannot
make copies of it. Here in the United
States we are fortunate that the same
disk based COMAL is available from
most local User Groups or may be
ordered directly from COMAL Users
Group, USA, Limited (for under $20).
These disks are NOT copy protected,
and you can legally make as many
copies as you want. It is this disk
based version of COMAL for the
Commodore 64 that I am going to talk
about here.
Once you have a COMAL disk, you must
load COMAL into the computer before
you can run any programs written in
COMAL. To load COMAL, turn on the
computer system, insert the COMAL
disk in the disk drive (label side
up), and type in the following lines
from BASIC (when you turn the
computer on, it has BASIC going - if
you are using a C128, it must be in
C64 mode). Remember to press the
RETURN key after each line:
LOAD "BOOT*",8
RUN
The screen will display some
information about COMAL and begin to
load COMAL into the computer. When
the language is finished loading, a
COMAL program called "HI" is
automatically RUN. The reason that
COMAL runs this program is that the
first program you loaded ("BOOT*")
set it up so it would. Most COMAL
0.14 disks from COMAL Users Group USA
include a "HI" program, and on most
of those disks the "HI" program is
specific to that disk. This sounds
complicated, and it is, but each one
was written to do certain things
needed for that disk. If you are
expected to do anything, directions
will be printed on the screen. For
now I just want you to get and run
COMAL.
WHAT DO I DO WITH COMAL?
The purpose of COMAL is for YOU to
learn how to write readable programs,
and one way to learn is to first look
at other peoples' work. I am going
detail certain commands here so that
you can do just that. The commands
will be listed in UPPERCASE, but type
them in as unshifted letters.
CAT
This command will show you what is on
the disk drive. The disk drive sends
the disk DIRECTORY (that's what it is
called) to the computer, and COMAL
prints it on the screen. The actual
listing shows more than just program
names. It shows how big they are,
their names, and the file type. Each
entry in the directory is called a
file, and there are four types of
files - PRG (program), SEQ
(sequential - data files), REL
(random - also data files), and USR
(special files). Unlike the BASIC
command:
LOAD "$",8
COMAL will not erase the program in
memory while showing a directory of a
disk. You can slow the scrolling
lines by holding down the CTRL key on
the upper left hand side of the
keyboard, or stop it by pressing the
RUN/STOP key (right below the CTRL
key). If you happen to have a dual
drive (a two drive unit) you can add
a '0' or a '1' after the command:
cat 0 (This is for drive 0)
cat 1 (This is for drive 1)
LOAD
Once you know what is on the disk,
you can load COMAL programs into
memory with this command. It is
similar to the BASIC LOAD command,
except the default is now the disk
drive, not the cassette. The
following is an example of loading a
program from the disk drive called
filename:
load "filename"
Only PRG type files can be loaded. Be
careful, because other languages,
like BASIC, also store their programs
as PRG files and COMAL 0.14 will
attempt to load any PRG type file. If
you are not sure whether or not a
program was written in COMAL 0.14,
load the program and LIST it. Only
COMAL 0.14 programs can be listed,
any other type of program (BASIC,
COMAL 2.0, etc) will not list. DO NOT
RUN PROGRAMS WHICH DO NOT LIST. If
you do, COMAL will become confused
and stop functioning. The only thing
to do after this has happened is to
turn the computer off and reload
COMAL.
LIST
Once a COMAL program is in memory,
you will want to be able to see it.
The command LIST will do just that,
it will list the program to the
screen. The first thing you will
notice is you will want to slow or
stop the listing (so you can study
it). Just like a catalog command, you
can use the CTRL key to slow, the
RUN/STOP key to stop, and, just for
LISTing a program, the space bar to
pause the listing.
You will notice that each line has a
number in front of it. These are
called "line numbers" and COMAL uses
them to keep track of the order of
the program lines. The order goes
from low (1) to high (9999), and you
can use any line number between them.
The LIST command can also be used to
show just part of a program. The
following are some Examples to do
just that:
list (all lines)
list 100-500
list 100-
list -500 (beginning to 500)
RUN
When the program you want has been
loaded into memory, you start the
program with the command RUN. The
computer does a quick scan of the
program to make sure it seems
correct, and starts executing with
the first line of the program. If an
error occurs while the program is
running, the program will stop
executing, and COMAL will print the
line number it is having the trouble
with, and what the problem is.
MAKING ERRORS
There is a very good chance that you
will make typing errors while trying
these commands. COMAL checks each
line you type for errors, and if it
cannot understand what you typed, it
will stop and give you an error
message. It might go out to the disk
drive and get the error message, or
it might just print the message
itself (that depends on whether you
have error messages in memory or
not). If you get an error, COMAL will
put the cursor on the part of the
line it is having trouble with so
DON'T PANIC. Just make the correction
and press the RETURN key again.
If the little red light on the disk
drive starts blinking on and off
while COMAL just sits there waiting
for you to type something, try typing
in the following command:
STATUS
This will print the error the disk
drive had to the screen. Check your
disk drive manual to find out what
the problem is.